﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form3 : Form
    {
        private int id;
        public Form3()
        {
            InitializeComponent();
        }

        //修改
        public Form3(int Id, string Name, int Age, string Sex, double Score)
        {
            InitializeComponent();

            this.id = Id;

            textBox1.Text = Name;
            textBox2.Text = Age.ToString();
            textBox3.Text = Sex;
            textBox4.Text = Score.ToString();
        }



        private void Form3_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            var name = textBox1.Text;
            var age = textBox2.Text;
            var sex = textBox3.Text;
            var score = textBox4.Text;

            if (this.id > 0)
            {
                var sql = string.Format("update Students set Name ='{0}',Age='{1}',Sex='{2}',Score='{3}' where Id = '{4}' ", name, age, sex, score, this.id);
                DBhelper.AddOrUpdateOrdelete(sql);

                MessageBox.Show("修改成功", "提示");

            }
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
    }
}
